package com.juzipi.demo.singleton.type8;

public class SingletonTest8 {
    public static void main(String[] args) {
        //枚举
        Singleton instance = Singleton.INSTANCE;
        Singleton instance1 = Singleton.INSTANCE;
        System.out.println(instance == instance1);
        System.out.println(instance.equals(instance1));
        System.out.println(instance.hashCode());
        System.out.println(instance1.hashCode());
        instance.sayOk();
    }
}

//实用枚举，可以实现单例
enum Singleton{
    INSTANCE; // 属性
    public void sayOk(){
        System.out.println("OK!");
    }

}